package com.imooc.activitiweb;


import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.Execution;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import javax.annotation.Resource;

/**
 * ces
 *
 * @author jzwu
 * @since 2021/3/21 0021
 */
@ActiveProfiles("cloud")
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = ActivitiwebApplication.class)
public class Part10_EventAndTask {
    @Resource
    private RuntimeService runtimeService;

    @Test
    public void singStart() {
        runtimeService.signalEventReceived("Signal_1tht539");
    }

    @Test
    public void msgBack() {
        Execution execution = runtimeService.createExecutionQuery()
                .messageEventSubscriptionName("Message_3ncanod")
                .processInstanceId("dd2f1864-8b14-11eb-81eb-00ff1104b4f4")
                .singleResult();
        runtimeService.messageEventReceived("Message_3ncanod",execution.getId());
    }
}